package com.qianli.cashmama.trade.client.bill.request;

import com.fqgj.common.api.ParamsObject;
import com.fqgj.common.utils.CollectionUtils;
import com.fqgj.exception.common.ApplicationException;
import com.qianli.cashmama.pay.client.enums.PaymentChannelEnum;
import com.qianli.cashmama.trade.client.vo.DiscountListVO;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/7/25
 * Time: 下午3:17
 */
public class BillPayRequest extends ParamsObject {
    private static final Logger LOGGER = LoggerFactory.getLogger(BillPayRequest.class);
    /**
     * 用户code
     */
    private String userCode;

    /**
     * 账单code
     */
    private List<String> billNoList;

    /**
     * 现金金额
     */
    private String capital;

    /**
     * 支付发起时间
     */
    private Date payDate;

    /**
     * 支付流水号
     */
    private String payBizNo;

    /**
     * 支付渠道
     */
    private PaymentChannelEnum paidChannel;

    /**
     * 支付渠道手续费
     */
    private BigDecimal paidChannelServiceFee;
    /**
     * 支付银行卡,也可以是支付宝号码
     */
    private String bankNo;

    /**
     * 优惠列表
     */
    private List<DiscountListVO> discountList;

    /**
     * 抵扣金额
     */
    private BigDecimal discountCapital;

    /**
     * 还款发起
     */
    private String operator = "system";

    private String tradeNo;

    /**
     * 还款使用的渠道 流水号
     */
    private String tripleNo;

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    @Override
    public void validate() {
        if (StringUtils.isEmpty(userCode) ||
                CollectionUtils.isEmpty(billNoList) ||
                (StringUtils.isEmpty(capital) && CollectionUtils.isEmpty(discountList)) ||
                StringUtils.isEmpty(payBizNo) ||
                paidChannel == null ||
                payDate == null) {

            LOGGER.error("== BillPayRequest 参数错误 ==,userCode:{},billNoList:{},capital:{},payBizNo:{},paidChannel:{},bankNo:{},payDate:{}", userCode, billNoList, capital, payBizNo, paidChannel, bankNo, payDate);
            throw new ApplicationException("Parameter error");
        }
    }

    public String getOperator() {
        return operator;
    }

    public BillPayRequest setOperator(String operator) {
        this.operator = operator;
        return this;
    }

    public String getBankNo() {
        return bankNo;
    }

    public BillPayRequest setBankNo(String bankNo) {
        this.bankNo = bankNo;
        return this;
    }

    public String getPayBizNo() {
        return payBizNo;
    }

    public BillPayRequest setPayBizNo(String payBizNo) {
        this.payBizNo = payBizNo;
        return this;
    }

    public PaymentChannelEnum getPaidChannel() {
        return paidChannel;
    }

    public BillPayRequest setPaidChannel(PaymentChannelEnum paidChannel) {
        this.paidChannel = paidChannel;
        return this;
    }

    public List<DiscountListVO> getDiscountList() {
        return discountList;
    }

    public BillPayRequest setDiscountList(List<DiscountListVO> discountList) {
        this.discountList = discountList;
        return this;
    }

    public BigDecimal getDiscountCapital() {
        return discountCapital;
    }

    public BillPayRequest setDiscountCapital(BigDecimal discountCapital) {
        this.discountCapital = discountCapital;
        return this;
    }

    public Date getPayDate() {
        return payDate;
    }

    public BillPayRequest setPayDate(Date payDate) {
        this.payDate = payDate;
        return this;
    }

    public String getCapital() {
        return capital;
    }

    public BillPayRequest setCapital(String capital) {
        this.capital = capital;
        return this;
    }

    public String getUserCode() {
        return userCode;
    }

    public BillPayRequest setUserCode(String userCode) {
        this.userCode = userCode;
        return this;
    }

    public List<String> getBillNoList() {
        return billNoList;
    }

    public BillPayRequest setBillNoList(List<String> billNoList) {
        this.billNoList = billNoList;
        return this;
    }

    public BigDecimal getPaidChannelServiceFee() {
        return paidChannelServiceFee;
    }

    public BillPayRequest setPaidChannelServiceFee(BigDecimal paidChannelServiceFee) {
        this.paidChannelServiceFee = paidChannelServiceFee;
        return this;
    }

    public String getTripleNo() {
        return tripleNo;
    }

    public BillPayRequest setTripleNo(String tripleNo) {
        this.tripleNo = tripleNo;
        return this;
    }
}
